package company.wangyi_F;

import java.util.*;

// 暴力解 遍历所有可能
// 一个物品可能去A，可能去B，可能丢弃
public class Wang3A {

    private static int result = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            int[] array = new int[n];
            int sum = 0;
            for (int j = 0; j < n; j++) {
                array[j] = sc.nextInt();
                sum += array[j];
            }
            helper(array, 0, 0, 0, sum);
            System.out.println(result);
        }
    }

    private static void helper(int[] array, int index, int a, int b, int notUsed) {
        if (index == array.length)
            return;
        if (a == b)
            result = Math.min(result, notUsed);
        // 东西给A 东西给B 东西扔掉
        helper(array, index + 1, a + array[index], b, notUsed - array[index]);
        helper(array, index + 1, a, b + array[index], notUsed - array[index]);
        helper(array, index + 1, a, b, notUsed);
    }
}
